package com.travel.group.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.travel.group.dao.NewsMapper;
import com.travel.group.entity.News;
import com.travel.group.service.NewsService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class NewsServiceImpl extends ServiceImpl<NewsMapper, News> implements NewsService {

    @Override
    public List<News> getByNewsIds(List<Integer> ids) {
        return baseMapper.selectBatchIds(ids);
    }

    @Override
    public List<News> getAllNewsInfo(Integer page, Integer limit) {
        PageHelper.startPage(page, limit);
        List<News> news = baseMapper.selectList(null);
        return news;
    }

    @Override
    public List<News> getAllNewsInfoPlus(Integer page, Integer limit, String name) {
        PageHelper.startPage(page, limit);
        List<News> news = baseMapper.selectList(new QueryWrapper<News>().like("name", name));
        return news;
    }

    @Override
    public Integer countData() {
        List<News> news = baseMapper.selectList(null);
        return news.size();
    }
}
